
package minipad;

import javax.swing.text.Caret;
import javax.swing.text.DefaultCaret;
import Modele.PressePapier;


/**
 * SingleTon Component buffer
 * @author David Phung, Michel Fraser
 */
public class InternalViewData{
	private static InternalViewData instance = null;
	private String buffer;
        private Character lastChar;
        private Caret caret;
        private MiniPadView vue;
        private boolean MacroEnabled;
        private PressePapier clipboard;

    private InternalViewData(MiniPadView Vue) {
        this.buffer = "";
        this.lastChar = null;
        this.caret = new DefaultCaret();
        this.vue = Vue;
        MacroEnabled=false;
        clipboard = PressePapier.getInstance();
    }

    public static InternalViewData getInstance(MiniPadView Vue) {
            if (instance == null) {
                    instance = new InternalViewData(Vue);
            }
            return instance;
    }

    public boolean isMacroEnabled() {
        return MacroEnabled;
    }

    public void setMacroEnabled(boolean MacroEnabled) {
        this.MacroEnabled = MacroEnabled;
    }


	public void setBuffer(String s) {
		buffer = s;
                
	}

	public String getBuffer() {
		return buffer;
	}

    public Caret getCaret() {
        return caret;
    }

    public void setCaret(Caret caret) {
        this.caret = caret;
        caret.setVisible(true);
        vue.setCaret(caret);
    }

    public String getPressePapier(){
        return clipboard.getBuffer();
    }

    public Character getLastChar() {
        return lastChar;
    }

    public void setLastChar(Character lastChar) {
        this.lastChar = lastChar;
    }

    public void setCaretPos(int p){
        caret.setDot(p);
    }

    public void setPressePapier(String pp){
        clipboard.setBuffer(pp);
    }

}
